package com.foruo.modules.demo.controller;

import com.foruo.modules.demo.entity.DemoEntity;
import com.foruo.modules.demo.service.DemoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * controller
 * @author GaoYuan
 * @date 2018/5/3 下午3:47
 */
@RestController
@RequestMapping("/demo")
public class DemoController {

    @Autowired
    DemoService demoService;


    /**
     * 获取详情
     *
     *     get用 @GetMapping
     *     post用 @PostMapping
     *
     *     简单传参用 @RequestParam  前台数据用form格式
     *     复杂数据用 @RequestBody 前台数据用json格式
     *
     *     返回数据统一是json
     */
    @GetMapping("/get")
    public DemoEntity getDemo(@RequestParam("id") String id){
        return demoService.get(id);
    }

}
